<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:103:"/Applications/XAMPP/xamppfiles/htdocs/smq/shangbiaowang/public/../application/index/view/index/now.html";i:1490952384;}*/ ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


</head>
<body>
<div style="margin:300px 300px 0;border-bottom:1px #000 solid">
</div>
<div id="div1"  style="height: 300px;
        top: 100px; left: 100px; width: 300px; position: absolute;" onmousedown="mouseDown(this,event)"
     onmousemove="mouseMove(event)" onmouseup="mouseUp(event)">0</div>
</body>
<script type="text/javascript">
    var mouseX, mouseY;
    var objX, objY;
    var isDowm = false;  //是否按下鼠标
    function mouseDown(obj, e) {
        obj.style.cursor = "move";
        objX = div1.style.left;
        objY = div1.style.right;
        mouseX = e.clientX;
        mouseY = e.clientY;
        isDowm = true;
    }
    function mouseMove(e) {
        var div = document.getElementById("div1");
        var x = e.clientX;
        var y = e.clientY;
        if (isDowm) {
            div.style.left = parseInt(objX) + parseInt(x) - parseInt(mouseX) + "px";
            div.style.right = parseInt(objY) + parseInt(y) - parseInt(mouseY) + "px";
            document.getElementById("span1").innerHTML = "x:" + div.style.right + "  " + "y:" + div.style.left;
        }
    }
    function mouseUp(e) {
        if (isDowm) {
            var x = e.clientX;
            var y = e.clientY;
            var div = document.getElementById("div1");
            div.style.left = (parseInt(x) - parseInt(mouseX) + parseInt(objX)) + "px";
            div.style.right = (parseInt(y) - parseInt(mouseY) + parseInt(objY)) + "px";
            document.getElementById("span2").innerHTML = "x:" + div.style.right + "  " + "y:" + div.style.left;
            mouseX = x;
            rewmouseY = y;
            div1.style.cursor = "default";
            isDowm = false;
        }
    }
</script>
</html>

